package com.atguigu.spzx.cloud.order.feign;

import com.atguigu.spzx.cloud.user.entity.User;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * projectName: com.atguigu.spzx.cloud.order.feign
 *
 * @author: 顾司羽
 * time: 2024/12/25 21:06 周三
 * description:
 */
@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable cause) {
        //Lambda表达式
        return userId -> {
            System.out.println("服务触发了降级处理了！！"+cause.getMessage());
            User user = new User();
            user.setId(userId);
            return user;
        };
    }
    }
/*        return new UserFeignClient() {
            @Override
            public User findUserByUserId(Long userId) {
                System.out.println("服务触发了降级处理了！！"+cause.getMessage());
                User user = new User();
                user.setId(userId);
                return user;
            }
        };
    }*/

